nginx Shell脚本rclone push to object storage在手动运行时有效,但不能以编程方式运行 | 您所在的位置:网站首页 › nginx 运行shell › nginx Shell脚本rclone push to object storage在手动运行时有效,但不能以编程方式运行 |
背景我有一个运行nginx-rtmp模块的docker容器在这个容器上我接收到一个rtmp流,它被记录下来,转换成hls并显示在一个html页面上通过hls的流式传输和显示工作正常目标 我的目标是录制大约一个小时(或一定的文件大小),然后保存录音,转换为mp4,推到一个对象存储桶,然后删除旧文件。(然后录制下一个小时等等) 当前实现我通过编写一个shell脚本实现了这一点,该脚本通过nginx-rtmp模块的exec_record_done函数执行我的nginx.conf: ... # RTMP configuration rtmp { server { ... application live { live on; recorder all { record all; record_path /var/www/html/stream/mp4; record_max_size 100000K; record_unique on; record_suffix _%d%m%Y_%H%M.flv; exec_record_done /bin/bash /scripts/cleaner.sh $path $dirname $basename; } ... } } } http { ... }我的剧本: #!/bin/bash path=$1 dirname=$2 basename=$3 newfile="${dirname}/${basename}.mp4" ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $newfile && rm $path TIME=$(/bin/date +%Y/%m/%d)&& rclone sync -P $newfile objstor:bucket/$TIME/ && rm $newfile问题当我手动运行脚本时,整个事情都按预期工作。但是当通过exec_record_done运行时,当达到录制的文件大小时(按预期),脚本生成mp4文件,删除flv(按预期),但不会推送到对象存储。我很难理解为什么当我手动运行脚本时它可以工作,但当通过exec_record_done运行时却不行。 |
CopyRight 2018-2019 实验室设备网 版权所有 |